package com.bjesc_b2c.app.appraiset.adapter;

import android.content.Context;
import android.widget.CompoundButton;

import com.bjesc_b2c.app.appraiset.R;

import java.util.ArrayList;
import java.util.List;

import app.pinggushi.bjesc.com.baserecyclerview.adapter.CommonAdapter;
import app.pinggushi.bjesc.com.baserecyclerview.adapter.base.ViewHolder;
import master_bean.CarForBean;

/**
 * Created by yidong on 2017/8/19.
 */

public class MoreCheckAdapter extends CommonAdapter<CarForBean> {
    private Context mContext;
    public List<CarForBean> checkList = new ArrayList<>();

    public MoreCheckAdapter(Context context, int layoutId, List<CarForBean> datas) {
        super(context, layoutId, datas);
    }

    @Override
    protected void convertView(ViewHolder holder, CarForBean bean, final int position) {
        holder.setText(R.id.cbProduk, bean.getName());
        holder.setOnCheckedChangeListener(R.id.cbProduk, new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    checkList.add(mDatas.get(position));
                } else {
                    if (checkList.contains(mDatas.get(position))) {
                        checkList.remove(mDatas.get(position));
                    }
                }
            }
        });
    }
}